package com.ruoyi.slope.data.fencenet.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.data.fencenet.domain.SlopeFencenetData;
import com.ruoyi.slope.data.fencenet.service.ISlopeFencenetDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 边坡防护网监测数据Controller
 * 
 * @author ruoyi
 * @date 2025-05-19
 */
@RestController
@RequestMapping("/data/fencenet")
public class SlopeFencenetDataController extends BaseController
{    
    @Autowired
    private ISlopeDataFileService slopeDataFileService;

    @Autowired
    private ISlopeFencenetDataService slopeFencenetDataService;

    /**
     * 查询边坡防护网监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('data:fencenet:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeFencenetData slopeFencenetData)
    {
        startPage();
        List<SlopeFencenetData> list = slopeFencenetDataService.selectSlopeFencenetDataList(slopeFencenetData);
        return getDataTable(list);
    }

    /**
     * 导出边坡防护网监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('data:fencenet:export')")
    @Log(title = "边坡防护网监测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeFencenetData slopeFencenetData)
    {
        List<SlopeFencenetData> list = slopeFencenetDataService.selectSlopeFencenetDataList(slopeFencenetData);
        ExcelUtil<SlopeFencenetData> util = new ExcelUtil<SlopeFencenetData>(SlopeFencenetData.class);
        String path = util.exportExcel(response, list, "边坡防护网监测数据数据");
        SlopeDataFile slopeDataFile = new SlopeDataFile();
        slopeDataFile.setFileName(path);
        slopeDataFileService.insertSlopeDataFile(slopeDataFile);
    }

    /**
     * 获取边坡防护网监测数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('data:fencenet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeFencenetDataService.selectSlopeFencenetDataById(id));
    }

    /**
     * 新增边坡防护网监测数据
     */
    @PreAuthorize("@ss.hasPermi('data:fencenet:add')")
    @Log(title = "边坡防护网监测数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeFencenetData slopeFencenetData)
    {
        return toAjax(slopeFencenetDataService.insertSlopeFencenetData(slopeFencenetData));
    }

    /**
     * 修改边坡防护网监测数据
     */
    @PreAuthorize("@ss.hasPermi('data:fencenet:edit')")
    @Log(title = "边坡防护网监测数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeFencenetData slopeFencenetData)
    {
        return toAjax(slopeFencenetDataService.updateSlopeFencenetData(slopeFencenetData));
    }

    /**
     * 删除边坡防护网监测数据
     */
    @PreAuthorize("@ss.hasPermi('data:fencenet:remove')")
    @Log(title = "边坡防护网监测数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeFencenetDataService.deleteSlopeFencenetDataByIds(ids));
    }
}
